<?php

namespace Home\Controller;
use Think\Controller;

class LoginController extends BaseController{
	
	public function index(){
		$this->display();
	}
	
	public function login(){
		if(IS_POST){
			   
				$mobile = I('mobile');
				$password = md5(I('password'));
				$res = M('user')->where("mobile = '{$mobile}' && password = '{$password}'")->find();
				if($res){
					//查找会员数据
					$info = M('user')->where("id = {$res['id']}")->find();
					session('user',$info);
					
					//是否禁用
					if($info['status']==0){
						$this->error('当前用户已被禁止，请联系管理员');
					}
					else{
						$this->redirect('Home/Index/index');
					}
					
				}else{
					$this->error('用户名或密码错误');
				}
			
		}
	}
 	public function logout(){
		session('user',null);
		$this->redirect('Home/Login/index');
	}
	
}

?>